package externalflame.systemdesign.newsfeed.controller;


import externalflame.systemdesign.newsfeed.dto.Page;
import externalflame.systemdesign.newsfeed.entity.Tweet;
import externalflame.systemdesign.newsfeed.service.TweetService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping(value = "/tweets")
public class TweetController {

    @Autowired
    TweetService tweetService;
    private Long maxId;

    @ApiOperation("查看推特")
    @GetMapping("/")
    public Page<Tweet> getTweets(@RequestHeader Long userId, @RequestParam Long pageSize, @RequestParam(required = false) Long maxId) {
        return tweetService.getMyTweets(userId, pageSize, maxId);
    }

    @ApiOperation("发推特")
    @PostMapping(value = "/", produces = "application/json")
    public Tweet postTweet(@RequestHeader Long userId, @RequestBody String content) {
        return tweetService.postTweet(userId, content);
    }

}
